//
//  BRCarInfoCarNumCellTableViewCell.m
//  carcareIOS
//
//  Created by 王然 on 16/8/2.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "BRCarInfoCarNumCell.h"

#define CELL_HEIGHT (120)


#define Word_Color (COLOR_HEXSTRING(@"#424242"))

#define Word_Wrong_Color (COLOR_HEXSTRING(@"#fd6500"))

@interface BRCarInfoCarNumCell()

@property (nonatomic , strong) UILabel * leftHeadTitleL;

@property (nonatomic , strong) UILabel * leftBottomTitleL;


@end

@implementation BRCarInfoCarNumCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    CGFloat labelX = 15 * __MAIN_RATIO_375;
    CGFloat leftLW = 70;
    self.leftHeadTitleL = [[UILabel labelWithFrame:CGRectMake(labelX, 0, leftLW, CELL_HEIGHT / 2) font:FONT_DEFAULT_Light(15) text:@"发动机号" textColor:[Theme wordColor]] setupOnView:self];
    
    CGFloat questionImageVLeft = self.leftHeadTitleL.right ;
    UIImage * questionImage = ImageNamed(@"enginAndClassNoQuestionImage");
    UIImageView * questionImagV = [[UIImageView imageViewWithFrame:CGRectMake(questionImageVLeft, (self.leftHeadTitleL.height - questionImage.size.height) / 2, questionImage.size.width, questionImage.size.height) image:questionImage] setupOnView:self];
    
    [[UIImageView imageViewWithFrame:CGRectMake(questionImageVLeft, self.leftHeadTitleL.bottom + (self.leftHeadTitleL.height - questionImage.size.height) / 2, questionImage.size.width, questionImage.size.height) image:questionImage] setupOnView:self];
    
    CGFloat addXY = 30;
    __weak __typeof(self) wself = self;
    UIButton * questionBtn = [[UIButton buttonWithFrame:CGRectMake(questionImagV.right - addXY, 0, questionImage.size.width + addXY * 2, CELL_HEIGHT) normalImage:nil click:^{
        if(wself.questionBtnClick)wself.questionBtnClick();
        
    }] setupOnView:self];
    [questionBtn setBackgroundColor:[UIColor clearColor]];
    
    self.engineNOTF = [[UITextField textFieldWithFrame:CGRectMake(questionBtn.right, 0, __MAIN_WIDTH - labelX - questionBtn.right, self.leftHeadTitleL.height) textColor:Word_Color font:FONT_DEFAULT_Light(16)] setupOnView:self];
    self.engineNOTF.textAlignment = NSTextAlignmentRight;
    self.engineNOTF.keyboardType = UIKeyboardTypeASCIICapable;
    self.engineNOTF.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
    self.engineNOTF.backgroundColor = [UIColor clearColor];
    self.engineNOTF.placeholder = @"请输入发动机号";
    self.engineNOTF.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    self.leftBottomTitleL = [[UILabel labelWithFrame:CGRectMake(labelX, self.leftHeadTitleL.bottom, self.leftHeadTitleL.width, self.leftHeadTitleL.height) font:self.leftHeadTitleL.font text:@"车架号码" textColor:[Theme wordColor]] setupOnView:self];
    
    
    self.classaNOTF = [[UITextField textFieldWithFrame:CGRectMake(self.engineNOTF.left, self.engineNOTF.bottom, self.engineNOTF.width, self.engineNOTF.height) textColor:Word_Color font:FONT_DEFAULT_Light(15)] setupOnView:self];
    self.classaNOTF.placeholder = @"请输入车架号码";
    self.classaNOTF.backgroundColor = [UIColor clearColor];
    self.classaNOTF.textAlignment = NSTextAlignmentRight;
    self.classaNOTF.keyboardType = UIKeyboardTypeASCIICapable;
    self.classaNOTF.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
    self.classaNOTF.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    //中间的线
    CGFloat lineX = 9;
    [[[UIView viewWithFrame:CGRectMake(lineX, self.engineNOTF.bottom - 0.5, __MAIN_WIDTH - lineX * 2 , 0.5)] setupOnView:self] resetBackgroundColor:[Theme lineColor]];
    [[[UIView viewWithFrame:CGRectMake(0, CELL_HEIGHT - 0.5, __MAIN_WIDTH , 0.5)] setupOnView:self] resetBackgroundColor:[Theme lineColor]];
}
- (void)reloadTextColorIsWrongTop:(BOOL)isTopWrong bottom:(BOOL)isBottomWrong
{
    [self.leftHeadTitleL setTextColor:(isTopWrong ? Word_Wrong_Color : Word_Color)];
    [self.engineNOTF setTextColor:(isTopWrong ? Word_Wrong_Color : Word_Color)];
    
    [self.leftBottomTitleL setTextColor:(isBottomWrong ? Word_Wrong_Color : Word_Color)];
    [self.classaNOTF setTextColor:(isBottomWrong ? Word_Wrong_Color : Word_Color)];
}
+ (CGFloat)getCellHeight
{
    return CELL_HEIGHT;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
